package com.jf.ss.base.service;

import com.jf.ss.base.mapper.LabelMapper;
import com.jf.ss.base.pojo.Label;
import com.jf.ss.common.utils.IdWorker;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LabelService {
    @Resource
    LabelMapper labelMapper;
    @Resource
    IdWorker idWorker;

    /**
     * 插入
     */
    public void insert(Label label) {
        label.setId(idWorker.nextId()+"");
        labelMapper.insert(label);
    }

    /**
     * 删除
     */
    public void delete(String id) {
        labelMapper.deleteByPrimaryKey(id);
    }

    /**
     * 更新
     */
    public void update(Label label) {
        labelMapper.updateByPrimaryKey(label);
    }

    /**
     * 通过id查找
     */
    public Label findById(String id) {
      return labelMapper.selectByPrimaryKey(id);
    }

    /**
     * 查找所有
     */
    public List<Label> findAll() {
       return labelMapper.selectAll();
    }

}
